home *** CD-ROM | disk | FTP | other *** search
- **** Leppard's wonderfully Random Number Generator V1.1 ****
-
- Rnd move.l #DateStore,d1 ;pointer to our date storage array
- CALLDOS DateStamp ;get date in Amiga format
- ;Random number generator.. from..
- clr.l d0
- clr.l d1
-
- move.b $bfe400,d0 ;CIA-A Timer A: Lo
- move.b $bfd600,d1 ;CIA-B Timer B: Lo
- eor.l d1,d0
- move.b $bfd400,d1 ;CIA-B Timer A: Lo
- and.l #%11111,d1
- rol.l d1,d0
- move.b $bfe7000,d1 ;CIA-A Timer B: Lo
- ror.l d1,d0
-
- move.w $dff004,d1 ;Raster screen pos
- eor.w d1,d0
- move.w $dff006,d1 ;Raster screen pos
- eor.w d1,d0
- move.l DateStore+8,d1 ;AmigaDATE!
- eor.l d1,d0
- move.l DateStore+4,d1
- eor.l d1,d0
- move.l DateStore,d1
- eor.l d1,d0
- move.l d0,d2
- swap d2 ;use 2nd word as another random source
- eor.w d2,d0
-
- addq.l #1,d3
- mulu d3,d0 ;d3 = max number + 1
- divu #65535,d0
- and.l #$0000FFFF,d0
-
- cmp.l d0,d3 ;d3 = max + 1 remember.. this is *POSSIBLE* just bloody unlikely (I think)
- bne Thepa
- subq.l #1,d0 ;make it max
- rts
-
- DateStore
- ds.l 3
-